package com.zl.ots.utils;

public class NamingConverterUtil {

    public static String camelToSnake(String input) {
        String result = input.replaceAll("([a-z])([A-Z])", "$1_$2");
        return result.toLowerCase();
    }

    public static String snakeToCamel(String input) {
        StringBuilder result = new StringBuilder();
        boolean toUpperCase = false;

        for (char c : input.toCharArray()) {
            if (c == '_') {
                toUpperCase = true;
            } else {
                if (toUpperCase) {
                    result.append(Character.toUpperCase(c));
                    toUpperCase = false;
                } else {
                    result.append(c);
                }
            }
        }

        return result.toString();
    }

}
